﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace BENBUN.UI.Forms
{
    public partial class LoadConfirmation : Form
    {
        private string _location;
        private string _country;
        private string _icon;

        public XmlDocument APIResponse
        {
            set
            {
                XmlNodeList nodes;

                try
                {
                    nodes = value.SelectNodes("/api/updateMode");
                    if (nodes[0].InnerText == "updated")
                    {
                        textBox1.Text = "The activity all ready existed on the WIW system, it has been updated.";
                    }
                    else
                    {
                        textBox1.Text = "The activity has been successfully added to the WIW database.";
                    }

                    nodes = value.SelectNodes("/api/geoLocation");
                    _location = nodes[0].InnerText;

                    nodes = value.SelectNodes("/api/geoCountry");
                    _country = nodes[0].InnerText;

                    labelCountry.Text = _country;
                    labelLocation.Text = _location;

                    nodes = value.SelectNodes("/api/icon");
                    _icon = nodes[0].InnerText;

                    switch (_icon)
                    {
                        case "1":
                            pictureBox1.Image = BENBUN.Properties.Resources._4_pin_running;
                            break;
                        case "2":
                            pictureBox1.Image = BENBUN.Properties.Resources._4_pin_running;
                            break;
                        case "3":
                            pictureBox1.Image = BENBUN.Properties.Resources._4_pin_cycling;
                            break;
                        case "4":
                            pictureBox1.Image = BENBUN.Properties.Resources._4_pin_hiking;
                            break;
                        case "5":
                            pictureBox1.Image = BENBUN.Properties.Resources._4_pin_rowing;
                            break;
                        case "6":
                            pictureBox1.Image = BENBUN.Properties.Resources._4_pin_swimming;
                            break;
                        case "7":
                            pictureBox1.Image = BENBUN.Properties.Resources._4_pin_skiing;
                            break;
                        default:
                            break;
                    }

                }
                catch (Exception)
                {

                    throw;
                }
            }

        }

        public LoadConfirmation()
        {
            InitializeComponent();

        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
    }
}
